package com.weixing.mall.provider.service.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.weixing.mall.provider.mapper.MemberPointMapper;
import com.weixing.mall.provider.model.domain.MemberPoint;
import com.weixing.mall.provider.model.dto.MemberPointDto;
import com.weixing.mall.provider.model.query.MemberPointQuery;
import com.weixing.mall.provider.model.vo.MemberPointVo;
import com.weixing.mall.provider.service.IMemberPointService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.xml.ws.Action;

/**
 * <p>
 * 会员积分模块 服务实现类
 * </p>
 *
 * @author Small
 * @since 2020-04-13
 */
@Service
public class MemberPointServiceImpl extends ServiceImpl<MemberPointMapper, MemberPoint> implements IMemberPointService {
   @Autowired
   private  MemberPointMapper memberPointMapper;
   /*
   *
   * 根据条件查询会员积分内容和列表
   * */
    @Override
    public IPage<MemberPointVo> selectOfPage(Page initMpPage, MemberPointQuery memberPointQuery) {
        return memberPointMapper.selectOfPage(initMpPage,memberPointQuery);
    }

    @Override
    public void addMemberPoint(MemberPointDto memberPointDto) {
        MemberPoint memberPoint = new MemberPoint();
        BeanUtils.copyProperties(memberPointDto,memberPoint);
        save(memberPoint);
    }

    @Override
    public IPage<MemberPointVo> selectOfPage(Page initMpPage, Long memberId) {
        //page(initMpPage,new LambdaQueryWrapper<MemberPoint>().eq(MemberPoint::getMemberId,memberId).orderByDesc(MemberPoint::getCreatedTime));
        return memberPointMapper.selectMemberOfPage(initMpPage,memberId);
    }
}
